﻿using GIMS.GUI.GeneralConfig;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GIMS.Def.Operators;
using GIMS.Def.Settings;
using GIMS.Def;
using GIMS.GUI.ArgumentControls;

namespace GIMS.GUI.Test
{
    /// <summary>
    ///This is a test class for GeneralConfigWindowViewModelTest and is intended
    ///to contain all GeneralConfigWindowViewModelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class GeneralConfigWindowViewModelTest
    {
        /// <summary>
        /// Reset GlobalSettings
        /// </summary>
        [TestInitialize()]
        public void MyTestInitialize()
        {
            GlobalSettings_Accessor.instance = null;
        }

        /// <summary>
        ///A test for GeneralConfigWindowViewModel Constructor with draw operator
        ///</summary>
        [TestMethod()]
        public void GeneralConfigWindowViewModelConstructorTest()
        {
            Operator imOperator = OperatorFactory.GetOperator("draw");
            GeneralConfigWindowViewModel viewModel = new GeneralConfigWindowViewModel(imOperator);
            Assert.IsTrue(viewModel.HasArgument);
            Assert.IsInstanceOfType(viewModel.ArgumentAsUiSetting.ArgumentControlElement, typeof(DrawArgumentControl)); 
            Assert.IsTrue(viewModel.HasSettings);
            Assert.AreEqual(3, viewModel.SettingsAsUiElements.Count);
        }

        /// <summary>
        ///A test for GeneralConfigWindowViewModel Constructor with GlobalSettings.
        ///</summary>
        [TestMethod()]
        public void GeneralConfigWindowViewModelConstructorTest1()
        {
            GeneralConfigWindowViewModel viewModel = new GeneralConfigWindowViewModel(GlobalSettings.Instance);
            Assert.IsFalse(viewModel.HasArgument);
            Assert.AreEqual(GlobalSettings.Instance.Settings.Count, viewModel.SettingsAsUiElements.Count);
        }
    }
}
